Skip to content

test(backend): Expand test coverage for commands, auth, services, and tasks#47

Merged
marevol merged 2 commits into
mainfrom
test/expand-backend-test-coverage
Feb 19, 2026
Merged

test(backend): Expand test coverage for commands, auth, services, and tasks#47
marevol merged 2 commits into
mainfrom
test/expand-backend-test-coverage

Conversation

@marevol

@marevol marevol commented Feb 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add comprehensive backend test coverage across management commands, authentication, services, views, serializers, and Celery tasks
  • 11 files changed with +1,360 lines of new/updated tests

Changes Made

New test modules

  • test_assign_owners_command.py — Tests for assign_owners management command (assign, dry-run, invalid user, no unowned records)
  • test_create_api_key_command.py — Tests for create_api_key command (create, invalid project/owner/scope, duplicate name, expiry)
  • test_create_test_users_command.py — Tests for create_test_users command (create, update, invalid format)
  • test_project_service.py — Tests for project service (create, duplicate name, cross-user isolation, get/delete owned, summary)
  • test_user_service.py — Tests for user service (list, create, change password, toggle active, delete)

Extended existing tests

  • test_authentication.py — RequireManagementScope permission (read/write/JWT), ambiguous API key prefix handling
  • test_data_post.py — Training data preview endpoint (returns data, n_rows param, unauthenticated 401, cross-owner denial)
  • test_event_views.py — Conversion event access control (API key wrong project, JWT non-owner, slot/project mismatch, API key auth for events)
  • test_serializers.py — Retraining schedule and deployment slot serializer validation
  • test_schedule_service.py — Added locmem cache fixture for Redis-free testing
  • test_tasks.py — Celery tasks for training, tuning, scheduled retraining, error/edge cases (missing data, cancelled jobs, unknown recommender)

Testing

  • All tests use pytest-django with @pytest.mark.django_db
  • In-memory cache (locmem) used where Redis is not available
  • Tests cover both happy paths and error/edge cases

Additional Notes

  • autouse locmem cache fixtures added to test modules that interact with Django cache (avoids Redis dependency in test runner)

marevol and others added 2 commits February 19, 2026 12:13
… tasks

Add new test modules for management commands (assign_owners, create_api_key,
create_test_users), project service, and user service. Extend existing tests
for authentication (scope permissions, ambiguous prefix), data upload
(preview endpoint, cross-owner access), event views (API key access control,
slot/project mismatch), serializers, schedule service, and Celery tasks
(training, tuning, scheduled retraining, error handling).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reformatted test files to comply with ruff style rules:
- Wrapped long assertion and argument lists across multiple lines
- Removed extra blank lines between decorators and fixtures
- Reformatted multi-parameter method signatures to one-arg-per-line

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marevol marevol merged commit 4df990a into main Feb 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant